package com.example.webdemo.controller;

import com.example.webdemo.bean.User;
import com.example.webdemo.common.ApiResult;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zp
 * @version 1.0
 * @description: 测试
 * @date 2023/6/24 16:29
 */
@RestController
public class TestController {

    @RequestMapping("/test")
    public ApiResult test() {
        return ApiResult.success();
    }

    @RequestMapping(value = "/testPost", method = RequestMethod.POST)
    public ApiResult testPost() {
        return ApiResult.success();
    }

    @RequestMapping(value = "/testPostData", method = RequestMethod.POST)
    public ApiResult testPostData(@RequestBody User user) {
        Map<String, Object> map = new HashMap<>();
        map.put("name", user.getName());
        map.put("sex", user.getSex());
        map.put("age", user.getAge());
        return ApiResult.success(map);
    }

    @RequestMapping(value = "/testUrl", method = RequestMethod.GET)
    public ApiResult testUrl(@RequestParam("id") String id) {
        Map<String, Object> map = new HashMap<>();
        map.put("name", "张三");
        map.put("sex", "man");
        map.put("age", 16);
        map.put("id", id);
        return ApiResult.success(map);
    }


}
